﻿package webCode {
	
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.URLRequest;
	import flash.net.URLLoader;
	
	public class MainApp extends MovieClip{

		var myWeb:Web;
		var webXML:XML;
		var gameStart:StartButton;
		var gamePause:PauseButton;
		var gameReset:ResetButton;
		
		public function MainApp() {
			trace("initializing mainApp");
			var getXML:URLRequest=new URLRequest("web.xml");
			var loadXML:URLLoader=new URLLoader(getXML);
			loadXML.addEventListener(Event.COMPLETE, onLoadXML);
		}
		
		public function onLoadXML(e:Event){
			webXML = new XML(e.target.data);
			init();
		}
		
		public function init():void
		{
			var temp:XML = webXML.webs[0].web[0];
			gameStart = new StartButton();
			gamePause = new PauseButton();
			gameReset = new ResetButton();
			
			myWeb = new Web(temp.@xVal, temp.@yVal, temp.@ringNum, temp.@radius, temp.@sides, stage.width, stage.height);
			addChild(myWeb);
			stage.addEventListener(MouseEvent.MOUSE_UP, myWeb.onrelease);
		}
		
	}
	
}
